﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.LogicalGroups.CApLGRLogicalGroupOperationsEnabler
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Collections;
using System.Collections.ObjectModel;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.DataTypes;


namespace DnProcessSimulateCommands.LogicalGroups;

public class CApLGRLogicalGroupOperationsEnabler : ITxCommandEnabler
{
  public bool Enable
  {
    get
    {
      bool enable = false;
      if (CApLGRLogicalGroupsUtil.IsDataLoaded())
      {
        ArrayList informationEntries = TxApplication.ActiveSelection.GetAllItemsInformationEntries();
        if (informationEntries.Count == 1)
        {
          if (informationEntries[0] is TxSelectionInformationEntry informationEntry2 && informationEntry2.SelectedObject is TxLogicalGroup)
          {
            if (((Collection<ITxObject>) CApLGRLogicalGroupsUtil.GetCompoundChildrenOfGroup(informationEntry2.SelectedObject as TxLogicalGroup)).Count > 0)
              enable = true;
          }
          else if (informationEntries[0] is TxSelectionTreeInformationEntry informationEntry1 && informationEntry1.Parent is TxLogicalGroup)
          {
            switch (((TxSelectionInformationEntry) informationEntry1).SelectedObject)
            {
              case TxCompoundPart _:
              case TxCompoundResource _:
                enable = true;
                break;
            }
          }
        }
      }
      return enable;
    }
  }
}
